<%--
  Created by IntelliJ IDEA.
  User: zhaojian
  Date: 2023/9/11
  Time: 14:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>员工列表</title>
</head>
<body>
<h1>员工列表</h1>
<a href="${pageContext.request.contextPath}/insert.jsp">添加员工</a>

<table width="800" border="1px solid #ccc">
  <tr>
    <td>id</td>
    <td>名字</td>
    <td>工资</td>
    <td>年龄</td>
    <td>操作</td>
  </tr>

  <c:if test="${list != null}">
    <c:forEach var="emp" items="${list}">
      <tr>
        <td>${emp.id}</td>
        <td>${emp.name}</td>
        <td>${emp.salary}</td>
        <td>${emp.age}</td>
        <td>
          <a href="${pageContext.request.contextPath}/jumpUpdate?id=${emp.id}">修改</a> &nbsp;&nbsp;&nbsp;&nbsp;
          <a href="${pageContext.request.contextPath}/delete?id=${emp.id}">删除</a>
        </td>
      </tr>
    </c:forEach>
  </c:if>
  <tr>
    <td colspan="5">
      <a href="${pageContext.request.contextPath}/empList?currentPage=1">首页</a> &nbsp;&nbsp;&nbsp;&nbsp;
      <%--   判断当前页大于等于第一页, 才有上一页按钮   --%>
      <c:if test="${currentPage > 1}">
        <a href="${pageContext.request.contextPath}/empList?currentPage=${currentPage-1}">上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
      </c:if>
      <%--  判断当前页小于等于总页数, 才有下一页按钮--%>
      <c:if test="${currentPage < pageHelper.totalPages}">
        <a href="${pageContext.request.contextPath}/empList?currentPage=${currentPage+1}">下一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
      </c:if>
      <font size="3">${currentPage}/${pageHelper.totalPages}</font>
    </td>
  </tr>
</table>
</body>
</html>
